﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BO.Infrastructure.Utils;
using BO.Video;
using GUI.Extensions;

namespace GUI.Services.Video
{
    /// <summary>
    /// Summary description for GetMostViewVideoByZone
    /// </summary>
    public class GetMostViewVideoByZone : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var zoneId = RequestExtensions.ZoneId;
            if (zoneId != -1)
            {
                var pageIndex = RequestExtensions.PageIndex;
                var pageSize = Math.Min(RequestExtensions.PageSize, 16);
                var dt = VideoBO.GetMostViewVideo(pageIndex, pageSize, zoneId: zoneId);
                if (dt != null && dt.Rows.Count > 0)
                {
                    context.Response.Write(PresentationUtils.ObjectToJson(dt));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}